:: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::  iNVMS-9000 Platform Complile Script 
:: 
::  Building Requires:
::	msvc >= 140
:: 
::  Tools Requires:
::  [perl](http:\\strawberryperl.com\) 
::  [nasm](https:\\www.nasm.us\)
:: 
::  Usage:
::  build_3rdpart.bat
:: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: echo off

:: VS Compile
:: call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64

:: title
:: title "3rdpart library build script"

:: multiple file compile
:: set CL=\MP

:: current directory
set baseDir=%CD%

:: Third libraries environment.
set archName=windows
set SRCDIR=%baseDir%\..
set SCRIPTSTDIR=%baseDir%
set PKTDIR=%baseDir%\dependence
set DEPDIR=%baseDir%\dependence\dept
set OUTDIR=%baseDir%\outdir\%archName%

:: System Path
set "PATH=%PATH%;%PROGRAMFILES(X86)%\Windows Kits\8.1\bin\x64"

:: Cmake
set "PATH=%PATH%;D:\cmake-3.18.0-rc1-win64-x64\bin"

if not exist %DEPDIR% (
    md %DEPDIR%
)

if not exist %OUTDIR% (
    md %OUTDIR%
)

echo "timestamp %DATA% %TIME%, current directory is %baseDir%, depdir is %DEPDIR%, output dir is %OUTDIR%"

:: googletest-1.15.2
echo "compile googletest-1.15.2..."
if not exist "%OUTDIR%\googletest-1.15.2\Debug\lib\gtest.lib" (
    if not exist "%DEPDIR%\googletest-1.15.2" (
        tar -xzvf %PKTDIR%\googletest-1.15.2.tar.gz -C %DEPDIR%\
    )
    cd %DEPDIR%\googletest-1.15.2
	md build
	cd build
	cmake -G"NMake Makefiles" -Dgtest_force_shared_crt=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=%OUTDIR%\googletest-1.15.2\Debug ..
    nmake install
) else (
    echo "googletest-1.15.2 libraries already exists, skip..."
)

cd %SCRIPTSTDIR%
pause